<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>录入入库单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/MyCommon.js"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <script src="../../js/MyCommon.js"></script>

</head>
<body>
<div class="layui-card-body ">
    <form class="layui-form" action=""  id="example" lay-filter="example">
        <!--类型-->
        <div class="layui-form-item">
            <!--  <label class="layui-form-label">类型：</label>
              <div class="layui-input-inline">
                  <select name="drType" lay-filter="drType">
                      <option value="">请选择</option>
                      <option value="10">袋装颗粒</option>
                      <option value="11">颗粒</option>
                      <option value="12">饮片</option>
                  </select>
              </div>-->

            <div class="layui-inline">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-inline">
                    <input type="text" name="drType" id="test17" lay-verify="required" readonly="readonly" placeholder=""
                           autocomplete="off" class="layui-input">
                </div>
            </div>


            <!--药品名称-->
            <div class="layui-inline">
                <label class="layui-form-label">药品名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="drName" id="test2" lay-verify="required" readonly="readonly" placeholder=""
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <!--数量-->
            <div class="layui-inline">
                <label class="layui-form-label">数量</label>
                <div class="layui-input-inline">
                    <input type="text" name="wareAmount" id="test3" lay-verify="required"  placeholder=""
                           autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <!--仓库单位-->
            <!--<div class="layui-inline">
                <label class="layui-form-label">仓库单位:</label>
                <div class="layui-input-inline">
                    <select name="drUnit" lay-filter="drUnit">
                        <option value="">请选择</option>
                        <option value="34">盒</option>
                        <option value="35">袋</option>
                    </select>
                </div>
            </div>-->

            <div class="layui-inline">
                <label class="layui-form-label">仓库单位</label>
                <div class="layui-input-inline">
                    <input type="text" name="drUnit" id="test16" lay-verify="required" placeholder=""
                           autocomplete="off" readonly="readonly" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">规格</label>
                <div class="layui-input-inline">
                    <input type="text" name="drSpecs" id="test5" lay-verify="required" placeholder=""
                           autocomplete="off" readonly="readonly" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">进货单价</label>
                <div class="layui-input-inline">
                    <input type="text" name="warePrice" id="test6" lay-verify="required" placeholder=""
                           autocomplete="off"  class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">进货总价</label>
                <div class="layui-input-inline">
                    <input type="text" name="warePriceTotal" id="test7" lay-verify="required" placeholder="数量X进货单价"
                           autocomplete="off"  class="layui-input"  >
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">批号</label>
                <div class="layui-input-inline">
                    <input type="text" name="wareBatchNumber" id="test8" lay-verify="required" placeholder=""
                           autocomplete="off" readonly="readonly" class="layui-input" value="">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">生产日期</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name = "drManufactureDate" id="test9" readonly="readonly" autocomplete="off">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">有效期</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="drValidityDate" id="test10" readonly="readonly"  >
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">生产厂家</label>
                <div class="layui-input-inline">
                    <input type="text" name="drFactory" id="test11" lay-verify="required"
                           class="layui-input" readonly="readonly" value="">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">原产地</label>
                <div class="layui-input-inline">
                    <input type="text" name="drProducingArea"  id="test12" lay-verify="required" placeholder=""
                           autocomplete="off" class="layui-input" readonly="readonly" value="">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">录入时间</label>
                <div class="layui-input-inline">
                    <input type="datetime" name="wareTime"  id="test14" lay-verify="required" placeholder=""
                           autocomplete="off" class="layui-input" readonly="readonly" value="">
                </div>
            </div>

            <div class="layui-inline" >
                <label class="layui-form-label">单据号</label>
                <div class="layui-input-inline">
                    <input type="datetime" name="documentNo"  id="test15" lay-verify="required" placeholder=""
                           autocomplete="off" class="layui-input" readonly="readonly" value="">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-inline">
                    <input type="text" name="wareRemarks" id="test13" lay-verify="required" placeholder=""
                           autocomplete="off" class="layui-input" readonly="readonly" value="">
                </div>
            </div>

            <div class="layui-inline" style="float:right" ;>
                <td colspan="6" align="right">
                    <button type="button" class="layui-btn layui-btn-warm" id="LAY-component-form-getval">保存</button>
                </td>
            </div>
        </div>
    </form>
</div>
</body>
</html>

<script>
    $(document).ready(function () {
        layui.use(['form', 'layedit', 'laydate','layer'], function() {
            var form = layui.form;
            var layer = layui.layer;
            var layedit = layui.layedit;
            var laydate = layui.laydate;

            //获取URL路径上的参数
            var documentNo = getQueryString("documentNo");
            // console.log(documentNo);
            var data;
            //发送请求，获取单据信息
            requestAjax("/JT90/confirm/queryWarehouse", "get", "json", "documentNo=" + documentNo, function (data) {
                if (data.success) {
                    data = data.result;
                    // console.log(data.result);
                } else {
                    layer.msg("查询数据失败")
                }

                var warTime = data.wareTime;
                var documentNo = data.documentNo;
                var warTime = data.wareTime;
                var  wareAmount=data.wareAmount;
                var warePrice=data.warePrice;
                var warePriceTotal=data.warePriceTotal;
                var wareBatchNumber=data.wareBatchNumber;
                var wareRemarks=data.wareRemarks;
                var drugs=data.drugs;

                var  drUnit;
                if(drugs.drUnit=34){
                    drUnit="盒";
                }else if(drugs.drUnit=35){
                    drUnit="袋";
                };
                var drName=drugs.drName;

                var drType;
                if(drugs.drType=10){
                    drType="袋装";
                }else  if(drugs.drType=11) {
                    drType = "颗粒";
                }else if(drugs.drType=12){
                    drType="饮片";
                }
                var drSpecs=drugs.drSpecs;
                var drManufactureDate=drugs.drManufactureDate;
                var  drValidityDate=drugs.drValidityDate;
                var  drFactory=drugs.drFactory;
                var  drProducingArea=drugs.drProducingArea;
                //表单赋值，渲染数据
                form.val('example', {
                    "wareTime": warTime
                    ,"documentNo": documentNo
                    ,"wareAmount":wareAmount
                    ,"warePrice":warePrice
                    ,"warePriceTotal":warePriceTotal
                    ,"wareBatchNumber":wareBatchNumber
                    ,"drUnit":drUnit
                    ,"drName":drName
                    ,"drType":drType
                    ,"drSpecs":drSpecs
                    ,"drManufactureDate":drManufactureDate
                    ,"drValidityDate":drValidityDate
                    ,"drFactory":drFactory
                    ,"drProducingArea":drProducingArea
                    ,"wareRemarks":wareRemarks
                });

            });
            layui.$('#LAY-component-form-getval').on('click', function(){
                //点击保存按钮 获取数量
                var wareAmount=$("#test3").val();
                //单价
                var warePrice=$("#test6").val();
                //总价
                var warePriceTotal=$("#test7").val();
                //单据号
                var documentNo=$("#test15").val();

                var params={"wareAmount":wareAmount,"warePrice":warePrice,"warePriceTotal":warePriceTotal,"documentNo":documentNo};
                // console.log(params);
                    requestAjax("/JT90/confirm/update", "get", "json", params, function (data) {
                        if(data.success){
                            layer.msg('已保存!', {
                                icon: 1,
                                time: 1500,
                                end: function () {
                                    //关闭当前弹窗
                                    xadmin.close();
                                    // 对父窗口进行刷新
                                    xadmin.father_reload();
                                }
                            });

                        }else{
                            alert(data.message);
                        }
                    })
            })

        })

    })

</script>


